package com.hd.trans.db.bean;


import com.hd.trans.db.greenDao.DaoSession;
import com.hd.trans.db.greenDao.HuDunLanguageDao;
import com.hd.trans.db.greenDao.LanguageRecordDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;

/**
 * Author:  yang
 * Date:    2020/01/07 10:23
 * Desc:    语音使用记录
 */
@Entity(
        indexes = {@Index(value = "isVoice,languageId", unique = true)}
)
public class LanguageRecord {

    @Id(autoincrement = true)
    private Long id;


    @Property(nameInDb = "is_voice")
    private boolean isVoice;//是否为语音页语言

    private Long languageId;//这是与语言关联的外键

    @ToOne(joinProperty = "languageId") //这个是注解绑定languageId
    private HuDunLanguage language;//对象--关联语言


    @Property(nameInDb = "trigger_time")
    private long triggerTime = 0; //触发时间


    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;


    /** Used for active entity operations. */
    @Generated(hash = 817938176)
    private transient LanguageRecordDao myDao;



    @Generated(hash = 1785583938)
    public LanguageRecord(Long id, boolean isVoice, Long languageId,
            long triggerTime) {
        this.id = id;
        this.isVoice = isVoice;
        this.languageId = languageId;
        this.triggerTime = triggerTime;
    }


    @Generated(hash = 351916531)
    public LanguageRecord() {
    }


    @Generated(hash = 1911749295)
    private transient Long language__resolvedKey;



    public Long getId() {
        return this.id;
    }


    public void setId(Long id) {
        this.id = id;
    }


    public boolean getIsVoice() {
        return this.isVoice;
    }


    public void setIsVoice(boolean isVoice) {
        this.isVoice = isVoice;
    }


    public Long getLanguageId() {
        return this.languageId;
    }


    public void setLanguageId(Long languageId) {
        this.languageId = languageId;
    }


    public long getTriggerTime() {
        return this.triggerTime;
    }


    public void setTriggerTime(long triggerTime) {
        this.triggerTime = triggerTime;
    }


    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1588601054)
    public HuDunLanguage getLanguage() {
        Long __key = this.languageId;
        if (language__resolvedKey == null || !language__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            HuDunLanguageDao targetDao = daoSession.getHuDunLanguageDao();
            HuDunLanguage languageNew = targetDao.load(__key);
            synchronized (this) {
                language = languageNew;
                language__resolvedKey = __key;
            }
        }
        return language;
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1659901765)
    public void setLanguage(HuDunLanguage language) {
        synchronized (this) {
            this.language = language;
            languageId = language == null ? null : language.getId();
            language__resolvedKey = languageId;
        }
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 418311291)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getLanguageRecordDao() : null;
    }







}
